package com.youxin.cpcenter.service.utils;

import com.youxin.busfoundation.common.BusinessException;
import com.youxin.busfoundation.enums.EnterpriseIdentifyStatus;
import com.youxin.busfoundation.enums.EnterpriseManagerType;
import com.youxin.busfoundation.enums.EnterprisePassStatus;
import com.youxin.cpcenter.dao.TbMemberInfoMapper;
import com.youxin.cpcenter.model.TbEntMemberIdentify;
import com.youxin.cpcenter.model.TbMemberInfo;
import com.youxin.foundation.utils.StringUtils;

/**
 * 会员工具类
 * @author yingde.cao
 *
 */
public class MemberInfoUtils {
	/**
	 * 查询会员
	 * @param mapper
	 * @param memberId
	 * @return
	 */
	public static TbMemberInfo isMemberInfo(TbMemberInfoMapper mapper,long memberId)
	{
		TbMemberInfo memeberInfo = mapper.selectByPrimaryKey(memberId);
		if (memeberInfo == null) {
			throw new BusinessException("无法查询到会员信息");
		}		
		return memeberInfo;
	}
	
//	public static TbMemberInfo isMemberInfoCompanyInfo(TbMemberInfoMapper mapper,long memberId)
//	{
//		TbMemberInfo memeberInfo = isMemberInfo(mapper,memberId);
//		if(StringUtils.isNullOrEmpty(memeberInfo.getCompanyUid()))
//		{
//			throw new BusinessException("无法查询到公司uid信息");
//		}
//		if(StringUtils.isNullOrEmpty(memeberInfo.getCompanyName()))
//		{
//			throw new BusinessException("无法查询到公司名称信息");
//		}
//		return memeberInfo;
//
//	}
	/**
	 * 获取用户信息,通过手机号
	 * @param mapper TbMemberInfoMapper
	 * @param mobile 手机号
	 * @return TbMemberInfo
	 */
	public static TbMemberInfo getMemeberInfo(TbMemberInfoMapper mapper,String mobile)
	{
		TbMemberInfo memberInfo=mapper.selectByMobile(mobile);
		return memberInfo;
	}
	
//	public static TbMemberInfo isMemberInfoAuth(TbMemberInfoMapper mapper,long memberId)
//	{
//		TbMemberInfo memeberInfo = mapper.selectByPrimaryKey(memberId);
//		if (memeberInfo == null) {
//			throw new BusinessException("无法查询到会员信息");
//		}
////		if(memeberInfo.getEnterprisePass().shortValue()!=EnterprisePassStatus.Pass.getValue())
////		{
////			throw new BusinessException("账号["+memeberInfo.getUsername()+"]并不是企业账号!");
////		}
//		return memeberInfo;
//	}
	
//	public static TbMemberInfo isMemberInfoAuth(TbMemberInfoMapper mapper,long memberId,String companyUid)
//	{
//		TbMemberInfo memeberInfo = mapper.selectByPrimaryKey(memberId);
//		if (memeberInfo == null) {
//			throw new BusinessException("无法查询到会员信息");
//		}
////		if(memeberInfo.getEnterprisePass().shortValue()!=EnterprisePassStatus.Pass.getValue())
////		{
////			throw new BusinessException("账号["+memeberInfo.getUsername()+"]并不是企业账号!");
////		}
//		if(!companyUid.equals(memeberInfo.getCompanyUid()))
//		{
//			throw new BusinessException("账号["+memeberInfo.getUsername()+"]并不是当前企业内账号!");
//		}
//		return memeberInfo;
//	}
	

	
	/**
	 * 企业认证
	 * @param memberIdentity
	 * @return boolean
	 */
	public static boolean isIdentity(TbEntMemberIdentify memberIdentity){
		return memberIdentity.getStatus().shortValue()==EnterpriseIdentifyStatus.Authenticated.getValue();
	}
	
}
